﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ServerPanel : BasePanel<ServerPanel>
{
    public UILabel labServerName;
    public UIButton btnServerList;
    public UIButton btnEnterGame;
    public UIButton btnBack;
    public override void Init()
    {
        Hide();
        btnBack.onClick.Add(new EventDelegate(() =>
        {
            Hide();
            LoginPanel.Instance.Show();
        }));
        //服务列表
        btnServerList.onClick.Add(new EventDelegate(() =>
        {
            Hide();
            ServerListPanel.Instance.Show();
        }));
        //进入游戏
        btnEnterGame.onClick.Add(new EventDelegate(() =>
        {
            
        }));
    }

    public override void Show()
    {
        base.Show();
        if (AccountMgr.Instance.lastServerId == 0)
        {
            return;
        }
        ServerItem item = ServerMgr.Instance.GetServer(AccountMgr.Instance.lastServerId);
        if (item == null)
        {
            return;
        }
        labServerName.text = string.Format("{0}区 {1}", item.id, item.name);
    }
}
